<template>
  <view class="Refused">
    <view class="top">
      <img style="width: 80%; margin: 0 auto"
        src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/YPC/12.png" />
      <p>
        <span style="
            width: 31%;
            display: inline-block;
            text-align: left;
            padding-left: 0%;
          ">鉴定申请</span>
        <span style="width: 31%; display: inline-block; text-align: center">合同签订</span>
        <span style="
            width: 31%;
            display: inline-block;
            text-align: center;
            padding-left: 12%;
          ">房屋整治</span>
      </p>
    </view>
    <view class="backgrounds"> </view>
    <view class="title"> 拒绝接单理由 </view>
    <view class="text">
      <u--textarea v-model="value1" placeholder="请输入拒绝接单理由" height="240" style="background: #eee; margin: 10px">
      </u--textarea>
    </view>
    <u-button @click="handleGotonext" style="
        margin-top: 0.3rem;
        width: 96%;
        position: fixed;
        bottom: 20rpx;
        left: 50%;
        transform: translateX(-50%);
      " text="提交" size="large" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))"></u-button>
    <u-toast ref="uToast"></u-toast>
  </view>
</template>

<script>
import {
  getDatalistForTree,
  ECAOpenDataView,
  ECAinsertDataView,
  ECAFileServerUpload,
  ECAPrepareGetFilesInfo,
  ECAPrepareLoadWorkflowScript,
  ECAPLoadSendFormData,
  ECAPlatSendTask,
  ECAExecProcedure,
} from "@/common/utils/api.js";
export default {
  data() {
    return {
      value1: "",
      row: {},
    };
  },
  methods: {
    async handleGotonext() {
      let time = Date.now();
      let data3 = {
        procName: "get_user_by_taskId",
        dtParams: JSON.stringify([
          {
            i_taskId: this.row.TASK_ID,
            "i_type":0
          },
        ]),
      };
      const user = await ECAExecProcedure(data3);
      const res1 = await ECAPLoadSendFormData(this.row.TASK_ID, time);
      //组织发送打回一下个环节的人员信息
      let newSendData = [];
      res1.SendData.forEach((item) => {
        if (item.TNID == 2 && item.PTNID == 1) {
          item.selected = true;
          newSendData.push(item);
        }
      });
      //
      let data1 = {
        taskId: this.row.TASK_ID,
        direction: 1,
        actionText: "",
        taskName: "",
        wfBoxGuid: "82c1d3c7-f56a-4414-8382-f06e13a9772e",
        wfGuid: "{48A968B4-A044-4115-A9DB-099029B2E011}",
        sendNodes: JSON.stringify([
          {
            TNID: 124,
            PTNID: 1,
            TEXT: user.Data[0]._USERNAME,
            WFNODEGUID: "{FA54F190-31A8-41A1-9CA8-798339A5FC68}",
            WFNODETYPE: 2,
            WFNODENAME: "鉴定机构",
            ISUSER: 1,
            USERID: user.Data[0]._USERID,
            USERNAME: user.Data[0]._USERNAME,
            SINGLEASSIGN: true,
            PREJUNCNODEGUID: "",
            SORTNUM: 0,
            selected: true,
          },
        ]),
        time: time,
      };
      if (uni.getStorageSync("isPer") == 2) {
        data1.wfBoxGuid = "6c629281-e9c7-4193-8c38-4b9b9fbd9ee3";
        data1.wfGuid = "{21F63828-EA18-419E-A64E-0B1603D54265}";
      }
      const res = await ECAPlatSendTask(data1);
      if (res.Success) {
        let data2 = {
          procName: "reject_online_commission",
          dtParams: JSON.stringify(
            [
              {
                i_pkid: this.row.PKID,
                i_ifjd: 6,
                i_jjly: this.value1,
              },
            ]
          ),
          time: time,
        };
        const res = await ECAExecProcedure(data2);
        this.showToast();
        uni.navigateTo({
        url: "/"
        });
        // uni.switchTab({
        //   url: '/',
        //   success() {
        //     let page = getCurrentPages().pop();
        //     if (page == undefined || page == null) return;
        //     page.onLoad();
        //   }
        // })
      }
    },
    showToast(params) {
      this.$refs.uToast.show({
        message: "发送成功",
        type: "success",
      });
    },
  },
  onLoad(options) {
    this.row = JSON.parse(options.data);
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: "拒绝理由",
      })
        .then((res) => { })
        .catch((err) => { });
    }
  },
};
</script>

<style lang="scss" scoped>
.Refused {
  height: 100vh;

  .backgrounds {
    height: 1rem;
    background: #eee;
  }

  .top {
    height: 30px;
    background: #ffffff;
    margin-bottom: 20px;
    padding-top: 25px;
    text-align: center;

    .origin {
      width: 22px;
      height: 22px;
      background: #007aff;
      border-radius: 50%;
      display: inline-block;
    }

    .line {
      width: 20vw;
      /*height: 1px;*/
      border: 1px dashed #007aff;
      display: inline-block;
    }
  }

  .title {
    padding: 0.6rem;
    font-size: 1.1rem;
    font-weight: 800;
  }
}
</style>